package de.zainodis.commons.model;

import de.zainodis.commons.LogCat;

/**
 * Determines how the entering of text is being handled/processed.
 * 
 * @author zainodis
 * 
 */
public enum SelectMode {

   /** Replaces the old value with the new value. */
   Replace,
   /** Appends the new value to the old value. */
   Insert;

   private static final String TAG = "SelectMode";

   /**
    * @param value
    *           a string representing a SelectMode.
    * @return the {@link SelectMode} representing the given string value. If the
    *         given value could not be resolved, the default select mode
    *         {@link SelectMode#Insert} is returned instead.
    */
   public static SelectMode parse(String value) {
	 try {
	    return SelectMode.valueOf(value);
	 } catch (IllegalArgumentException e) {
	    LogCat.e(TAG, "Failed to convert " + value);
	 }
	 // Return the default
	 return Insert;
   }
}
